package com.fmm.easy;

import java.util.Stack;

public class MyQueue {
    private Stack<Integer> in = new Stack<>();
    private Stack<Integer> out = new Stack<>();

    private int count = 0;
    public MyQueue() {

    }

    public void push(int x) {
        while (!out.isEmpty()) {
            in.push(out.pop());
        }
        count++;
        in.push(x);
    }

    public int pop() {
        while (!in.isEmpty()) {
            out.push(in.pop());
        }
        count--;
        return out.pop();
    }

    public int peek() {
        while (!in.isEmpty()) {
            out.push(in.pop());
        }
        return out.peek();
    }

    public boolean empty() {
        return count == 0;
    }
}
